$(function(){
	
	window.localStorage.setItem('class',10);
	getData(0);
});
var baseurl = 'http://kt.zhangzhengjiang.top/api/';
var static_url = 'http://kt.zhangzhengjiang.top/';
/*
	获取班级分类数据
*/
// function getClassData(classid){
// 	page =1;
// 	window.localStorage.setItem('class',classid);
// }
// function getTypeData(type){
// 	page =1;
// 	window.localStorage.setItem('type',type);
	
// }

function getQueryVariable(variable)
{
       var query = window.location.search.substring(1);
       var vars = query.split("&");
       for (var i=0;i<vars.length;i++) {
               var pair = vars[i].split("=");
               if(pair[0] == variable){return pair[1];}
       }
       return(false);
}
var page = 1;
//筛选
function getData(type){
	$('#classInfo').html('');
	var ketangtype = getQueryVariable('tid');
	layer.open({
		type: 2
		,content: '正在加载...'
	  });
	$.ajax({
		url:baseurl+'index/getClass',
		type:'post',
		data:{type:type,ketangtype:ketangtype,page:page},
		success:function(res){
			layer.closeAll();
			console.log(res);
			if(res.code == 1){
			  //轮播
			  var data = res.data;
			  var data_html = '';
			  if(data.length == 0){
				$('#classInfo').html('');
				$('#classInfo').html('<img class="no_sku" src="images/zwsj.png">');
				return false;
			  }
			 page++;
			  for (var i = 0; i < data.length; i++) {
				 // data_html+='<a href="classLists.html?kid='+data[i].id+'">';
				 // 	data_html+='<li class="aui-list-item aui-border-b-0 aui-list-item-middle aui-padded-r-15 aui-background-white">';
				 // 		data_html+='<div class="aui-media-list-item-inner" style="align-items: center;">';
				 // 			data_html+='<div class="aui-list-item-media wechat-avatar aui-list-media-img" style="width: 4rem;">';
				 // 				data_html+='<img src="'+static_url+data[i].images+'" class="aui-radius-five">';
				 // 			data_html+='</div>';
				 // 			data_html+='<div class="aui-list-item-inner aui-padded-l-10 aui-position-relative" style="height: 4rem;">';
				 // 				data_html+='<p class="aui-color-three aui-font-size-14">'+data[i].title+'</p>';
				 // 				data_html+='<p class="aui-font-size-12 aui-ellipsis-1">'+data[i].content+'</p>';
				 			
				 // 			data_html+='</div>';
				 // 			data_html+='<div class="aui-text-default aui-margin-t-5">';
				 // 				data_html+='<i class="aui-iconfont aui-icon-right"></i>';
				 // 			data_html+='</div>';
				 // 		data_html+='</div>';
				 // 	data_html+='</li>';
				 // data_html+='</a>';
				 data_html+='<a href="classLists.html?kid='+data[i].id+'">';
				 	data_html+='<li class="aui-list-item aui-border-b-0 aui-list-item-middle aui-padded-r-15 aui-background-white">';
				 		data_html+='<div class="aui-media-list-item-inner" style="align-items: center;">';
				 			data_html+='<div class="aui-list-item-media wechat-avatar aui-list-media-img aui-position-relative" style="width: 4rem;">';
				 				data_html+='<img src="'+static_url+data[i].images+'" class="aui-border-radius">';
				 				data_html+='<div class="aui-lists-plays aui-position-absolute aui-width-one aui-lists-redio aui-flx-space aui-padded-l-5 aui-padded-r-5">';
				 					data_html+='<p class="aui-text-white aui-font-size-12">';
				 						data_html+='<img src="images/ear.png" alt="" class="aui-pull-left"><span class="aui-font-size-12 trans-eight aui-style-normal">'+data[i].pay_num+' 人</span>'; 
				 					data_html+='</p>';
				 					data_html+='<span>';
				 						data_html+='<img src="images/plays.png" alt="">';
				 					data_html+='</span>';
				 				data_html+='</div>';
				 			data_html+='</div>';
				 			data_html+='<div class="aui-list-item-inner aui-padded-l-10 aui-padded-t-0" style="height: 4rem;">';
				 				data_html+='<p class="aui-color-three aui-font-size-14 aui-ellipsis-1">'+data[i].title+'</p>';
				 				data_html+='<p class="aui-margin-t-5 aui-font-size-12 aui-ellipsis-2">'+data[i].content+'</p>';
				 			data_html+='</div>';
				 			data_html+='<div class="aui-text-default aui-margin-t-5">';
				 				data_html+='<i class="aui-iconfont aui-icon-right aui-font-size-12"></i>';
				 			data_html+='</div>';
				 		data_html+='</div>';
				 	data_html+='</li>';
				 data_html+='</a>';
			  }
			  $('#classInfo').html(data_html);
			}else{
				layer.open({
					content: res.msg
					,skin: 'msg'
					,time: 2 ,//2秒后自动关闭
					
				});
			}
		}
	})
}